$(function(){
		var btlogin = document.getElementsByName("submit")[0];
		btlogin.onclick=function(){
			var loginaccount = document.getElementsByName("loginaccount").value;
			var pwd = document.getElementsByName("password").value;
			if (loginaccount.length==0){
				alert("用户名不能为空")
				return
			}else if (pwd.length==0){
				alert("密码不能为空")
				return
			}
			var formData = new FormData($('input[name="myform"]')[0]);
			var xhr = null;
			try{
				xhr = new XMLHttpRequest();
			}catch(e){
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xhr.open("POST","/login.html/",true);
			xhr.send(formData);
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4){
					if(xhr.status == 200){
						result=xhr.responseText;
						var object = eval("("+result+")");
						if(object.status==200){
							alert("登录成功")
							window.location.href="/index.html/"
						}else if(object.status==121){
							alert("用户名不存在")
						}else if(object.status==122){
							alert("密码错误")
						}
					}
				}
			}
		}
	})